net: NAD live update VM localnet test#5039
Conversation
📝 WalkthroughWalkthroughThis PR consolidates network testing helpers into shared libraries, enhances localnet VM provisioning with runtime command support, introduces new test fixtures for baseline connectivity validation, and refactors existing l2_bridge tests to use the consolidated helpers instead of local implementations. ChangesNetwork Test Helper Refactoring and Localnet Test Suite
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Report bugs in Issues Welcome! 🎉This pull request will be automatically processed with the following features: 🔄 Automatic Actions
📋 Available CommandsPR Status Management
Review & Approval
Testing & Validation
Container Operations
Cherry-pick Operations
Label Management
✅ Merge RequirementsThis PR will be automatically approved when the following conditions are met:
📊 Review ProcessApprovers and ReviewersApprovers:
Reviewers:
Available Labels
AI Features
💡 Tips
For more information, please refer to the project documentation or contact the maintainers. |
Review Summary by QodoImplement NAD live-update test for localnet with helper refactoring
WalkthroughsDescription• Refactor shared NAD and connectivity helpers for reuse across test packages • Implement NAD live-update test for localnet with VLAN switching validation • Add cloud-init runcmd support to localnet_vm for ARP isolation configuration • Add localnet constants for interface and network naming standardization Diagramflowchart LR
A["Shared Helpers"] -->|Move to libs| B["libs/net/nad_ref.py"]
A -->|Move to tests| C["tests/network/libs/connectivity.py"]
D["localnet_vm Enhancement"] -->|Add runcmd param| E["Cloud-init ARP isolation"]
F["New Constants"] -->|IFACE_A/B, CUDN_B| G["Localnet NAD Ref Test"]
B -->|Used by| G
C -->|Used by| G
E -->|Used by| G
File Changes1. libs/net/nad_ref.py
|
Code Review by Qodo
1. Bare import pytest added
|
8885362 to
b71168f
Compare
|
Change: add runcmd to localnet vm docstring |
|
Change: drop move of assert connectivity helpers and use poll connectivity helper in test with params |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/network/libs/nad_ref.py`:
- Line 18: Remove the defensive "or []" fallback so a missing networks attribute
fails fast: replace the expression "deepcopy(vm.template_spec.networks) or []"
with a plain deepcopy(vm.template_spec.networks) so that an
AttributeError/TypeError is raised when vm.template_spec.networks is None;
update any surrounding logic that assumed an empty list to instead allow the
exception to propagate (or explicitly validate upstream), and ensure the call to
vm.set_networks(networks=...) receives the real copied value from
deepcopy(vm.template_spec.networks).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: a6fbe6c5-90f9-44a7-a02e-79d8f5498d01
📒 Files selected for processing (6)
tests/network/l2_bridge/nad_ref_change/lib_helpers.pytests/network/l2_bridge/nad_ref_change/test_nad_ref_change.pytests/network/libs/nad_ref.pytests/network/localnet/liblocalnet.pytests/network/localnet/nad_ref_change/conftest.pytests/network/localnet/nad_ref_change/test_nad_ref_change.py
💤 Files with no reviewable changes (1)
- tests/network/l2_bridge/nad_ref_change/lib_helpers.py
|
/verified Smoke as requested by bot: |
Test execution plan request detailsCRITICAL: You MUST post an inline review comment on the first changed line of the first file. As an expert software testing engineer, analyze all modified files in this PR and create a targeted test execution plan. Analysis Requirements:
Output rules: Your deliverable: Test Execution Plan
Guidelines:
Hardware-Related Checks (SR-IOV, GPU, DPDK): When PR modifies fixtures for hardware-specific resources:
CRITICAL WORKFLOW COMPLETION RULES: When responding to this test execution plan request, you MUST follow these rules EXACTLY:
ABSOLUTE PROHIBITIONS (violating these creates empty/meaningless reviews):
Remember: The pull request review is visible to users. Additional comments are redundant noise. CRITICAL — Verification rules for smoke and gating decisions: |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -e
echo "=== PR files changed ==="
gh api repos/RedHatQE/openshift-virtualization-tests/pulls/5039/files \
--jq '[.[] | .filename]' 2>/dev/null
echo ""
echo "=== Modified symbols: libs/net/nad_ref.py ==="
grep -n "^def " libs/net/nad_ref.py 2>/dev/null || echo "file not found"
echo ""
echo "=== Modified symbols: tests/network/libs/ ==="
ls tests/network/libs/ 2>/dev/null || echo "dir not found"
grep -rn "^def " tests/network/libs/ 2>/dev/null || echo "no defs"
echo ""
echo "=== Modified symbols: tests/network/localnet/liblocalnet.py ==="
grep -n "^def \|^IFACE_A_NAME\|^IFACE_B_NAME\|^CUDN_B_NAME\|^runcmd" tests/network/localnet/liblocalnet.py 2>/dev/null || echo "not found"
echo ""
echo "=== Modified symbols: tests/network/l2_bridge/nad_ref_change/lib_helpers.py ==="
grep -n "^def \|^NET_SEED\|^GUEST_IFACE" tests/network/l2_bridge/nad_ref_change/lib_helpers.py 2>/dev/null || echo "not found"
echo ""
echo "=== 6b: Callers of update_nad_references ==="
rg -rn "update_nad_references" tests/ libs/ 2>/dev/null || echo "none"
echo ""
echo "=== 6b: Callers of localnet_vm ==="
rg -rn "localnet_vm" tests/ 2>/dev/null || echo "none"
echo ""
echo "=== 6b: Callers of assert_connectivity / assert_no_connectivity (current state) ==="
rg -rn "assert_connectivity\|assert_no_connectivity" tests/ 2>/dev/null || echo "none"
echo ""
echo "=== 7: Smoke-marked test files ==="
rg -rl "`@pytest.mark.smoke`" tests/ 2>/dev/null || echo "none"
echo ""
echo "=== 8: Gating-marked test files ==="
rg -rl "`@pytest.mark.gating`" tests/ 2>/dev/null || echo "none"
echo ""
echo "=== Smoke/gating in localnet or l2_bridge paths ==="
rg -rn "`@pytest.mark.smoke`\|`@pytest.mark.gating`" tests/network/localnet/ tests/network/l2_bridge/ 2>/dev/null || echo "none"
echo ""
echo "=== First changed file in PR (for inline comment target) ==="
gh api repos/RedHatQE/openshift-virtualization-tests/pulls/5039/files \
--jq '.[0] | {filename: .filename, first_hunk_pos: (.patch | split("\n") | to_entries | map(select(.value | startswith("+"))) | .[0].key + 1)}' 2>/dev/null || echo "failed"
echo ""
echo "=== Get commit SHA ==="
gh api repos/RedHatQE/openshift-virtualization-tests/pulls/5039 --jq '.head.sha' 2>/dev/nullLength of output: 14374 🏁 Script executed: #!/bin/bash
COMMIT_SHA="7b6aebe8256a87f8551bb44bc1deb413540ae64e"
gh api repos/RedHatQE/openshift-virtualization-tests/pulls/5039/comments \
--method POST \
--field body='**Test Execution Plan**
- **Run smoke tests: True** — `tests/network/localnet/test_default_bridge.py` (smoke) → fixtures in `tests/network/localnet/conftest.py` → calls `n()` = `localnet_vm()` in `tests/network/localnet/liblocalnet.py` (modified: new `runcmd` parameter)
- **Run gating tests: False** — No gating-marked test file is in the affected set. All gating-marked tests are in `tests/virt/` and `tests/storage/` paths with no traced dependency on `localnet_vm()` or `update_nad_references`.
**Affected tests to run:**
| Test path | Reason |
|-----------|--------|
| `tests/network/localnet/nad_ref_change/test_nad_ref_change.py` | New test — primary validation target |
| `tests/network/l2_bridge/nad_ref_change/test_nad_ref_change.py` | Imports `n` (previously `update_nad_references`) from moved `tests/network/libs/nad_ref.py` |
| `tests/network/localnet/test_default_bridge.py` **(smoke)** | Transitive: fixtures in `tests/network/localnet/conftest.py` → `n()` = `localnet_vm()` (modified) |
| `tests/network/localnet/test_ovs_bridge.py` | Transitive: same conftest → `localnet_vm()` (modified) |
| `tests/network/localnet/ipam/` | Transitive: `ipam/conftest.py` → `n()` = `localnet_vm()` (modified) |
| `tests/network/localnet/migration_stuntime/` | Transitive: `migration_stuntime/conftest.py` → `n()` = `localnet_vm()` (modified) |' \
--field commit_id="$COMMIT_SHA" \
--field path='tests/network/l2_bridge/nad_ref_change/lib_helpers.py' \
--field position=1 \
2>&1Length of output: 5635 |
|
/approve |
|
New container for quay.io/openshift-cnv/openshift-virtualization-tests:latest published |
|
/cherry-pick cnv-4.22 |
|
Cherry-picked PR net: NAD live update VM localnet test into cnv-4.22: #5137 |
What this PR does / why we need it:
Implements the NAD reference change test for localnet: verifies that a running VM can switch its secondary localnet network from one VLAN to another without rebooting, and that TCP connectivity is established on the new VLAN.
Which issue(s) this PR fixes: -
Special notes for reviewer:
Usage of shared localnet setup: NNCP and localnet CUDN (as CUDN-VLAN-A)
Includes move of shared helpers to be used in several packages like upcoming metrics nad ref change test.
Exception ticket for backporting to 4.22: https://redhat.atlassian.net/browse/CNV-88886
jira-ticket: https://redhat.atlassian.net/browse/CNV-80573
Summary by CodeRabbit
Tests
Refactoring